package com.zxl.live.screen.ui.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.zxl.live.screen.R;
import com.zxl.live.tools.base.BaseAppCompatActivity;
import com.zxl.live.tools.tools.AppUtils;

/**
 * Created by Administrator on 2017/11/23.
 */

public class FeedbackActivity extends BaseAppCompatActivity implements View.OnClickListener {

    private EditText mEditText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_feedback);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(this);
        findViewById(R.id.feedback_commitBtn).setOnClickListener(this);
        mEditText = (EditText) findViewById(R.id.feedback_content);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.feedback_commitBtn:
                Editable text = mEditText.getText();
                if (TextUtils.isEmpty(text)) {
                    Toast.makeText(this, R.string.empty_fb, Toast.LENGTH_SHORT).show();
                    return;
                }
                try {
                    Intent data = new Intent(Intent.ACTION_SENDTO);
                    data.setData(Uri.parse("mailto:zxling0122@gmail.com"));
                    data.putExtra(Intent.EXTRA_SUBJECT, "Feedback : " + AppUtils.getAppName(this, getPackageName()) + " " + AppUtils.getVersionNameByPkgName(this, getPackageName()));
                    data.putExtra(Intent.EXTRA_TEXT, text.toString());
                    startActivity(data);
                    finish();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                break;
            default:
                onBackPressed();
                break;
        }
    }
}
